<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link href="css/mui.min.css" rel="stylesheet" />
		<link href="style/fjol_style.css" rel="stylesheet" />
	</head>

	<body>
		
		
		<nav class="mui-bar mui-bar-tab" >
			<a id="defaultTab" class="mui-tab-item mui-active" href="xol_index">
				<span class="mui-icon home-icon"></span>
				<span class="mui-tab-label">首页</span>
			</a>
			<a id="buyTab" class="mui-tab-item" href="xol_agent_list">
				<span class="mui-icon agent-icon"></span>
				<span class="mui-tab-label">经纪人</span>
			</a>
			<a class="mui-tab-item menuHouse"style="overflow: initial;" href="tagMenu">
				<span class="publish-icon"></span>
				<span class="mui-tab-label">发布</span>
			</a>
			<a id="sellTab" class="mui-tab-item" href="fj_selles">
				<span class="mui-icon sellhouse-icon"></span>
				<span class="mui-tab-label">托管</span>
			</a>
			<a class="mui-tab-item" href="my_page">
				<span class="mui-icon user-icon"></span>
				<span class="mui-tab-label">个人中心</span>
			</a>
		</nav>

		<script src="js/mui.min.js"></script>
		<script src="js/fj_public_js.js"></script>
		<script language='javascript' src='js/md5.js'></script>
		<script src="js/network.js"></script>
		<script src="js/enum.util.js"></script>
		<script src="js/common.util.js"></script>
		<script src="js/fj_base_data.js"></script>
		<script src="js/fj_area_util.js"></script>
		<script type="text/javascript" charset="utf-8">
			//mui初始化
			mui.init(

				);
				

			function plusReady(){
				
				//子页面加载内容，这个时候不让子页面展示，弹出等待框，
				//提示用户“数据正在加载”，当子页面的内容完全加载完毕后，再展示
				var nwaiting = plus.nativeUI.showWaiting();  
				webviewShow = plus.webview.create();
				
				
				var net = fjNetwork;
				//自动登录
				var userInfo = common.myStorage.getItem('userInfo');
				if(userInfo) {
					var loginToken = common.myStorage.getItem('loginToken');

					if(loginToken.length != 0) {
						var param = [{
							key: 'userId',
							value: userInfo.id
						}, {
							key: 'loginToken',
							value: loginToken
						}];
						net.post('user/valid-login-token.json', param, function(data) {
							//mui.toast(data.msg);
						}, function(message) {
							//mui.toast('账号信息过期');
						});
					}
				}
				
				getBaseData(net);
				var areaUtil = areaUtils;
				areaUtil.setNetworkClient(net);
				//获取城市列表
				var areaLevelCity = 2;
				
				areaUtil.getAreaListByLevel(areaLevelCity,function(){
					
					var currentCity = areaUtil.getCurrentCity();

					if(currentCity==null){
						areaUtil.setCurrentCityByCityName('泉州市');
					}
					
				});		

				var childAreaList = areaUtil.getCurrentCityChileAreaList();
				
			}
			
			document.addEventListener("plusready",plusReady,false);
			
		
		
			var subpages = ['xol_index.html', 'xol_agent_list.html', 'tagMenu.html', 'fj_selles.html', 'my_page.html'];
			var subpageIds = ['xol_index', 'xol_agent_list','tagMenu', 'fj_selles', 'my_page'];
			var subpage_style = {
				top: '0px',
				bottom: '51px'
			};

			var aniShow = {};

			//当前激活选项
			var activeTab = subpageIds[0];
			
			//创建子页面，首个选项卡页面显示，其它均隐藏；
			mui.plusReady(function() {
			
				var self = plus.webview.currentWebview();
				for(var i = 0; i < 5; i++) {
					var temp = {};
					var sub = plus.webview.create(subpages[i], subpageIds[i], subpage_style);
					if(i > 0) {
						sub.hide();
					} else {
						temp[subpageIds[i]] = "true";
//						temp[0] = "true";
						mui.extend(aniShow, temp);
					}
					self.append(sub);
				}
				
				
			});
			//选项卡点击事件
			mui('.mui-bar-tab').on('tap', 'a', function(e) {
				var targetTab = this.getAttribute('href');
				if(targetTab == activeTab) {
					return;
				}
				//显示目标选项卡
				//若为iOS平台或非首次显示，则直接显示
				if(mui.os.ios || aniShow[targetTab]) {
					plus.webview.show(targetTab);
//					console.log(targetTab);
				} else {
					//否则，使用fade-in动画，且保存变量
					var temp = {};
					temp[targetTab] = "true";
					mui.extend(aniShow, temp);
					plus.webview.show(targetTab, "fade-in", 300);
				}
				//隐藏当前;
				plus.webview.hide(activeTab);
				//更改当前活跃的选项卡
				activeTab = targetTab;
			});
			//自定义事件，模拟点击“首页选项卡”
			document.addEventListener('gohome', function() {
				var defaultTab = document.getElementById("defaultTab");
				//模拟首页点击
				mui.trigger(defaultTab, 'tap');
				//切换选项卡高亮
				var current = document.querySelector(".mui-bar-tab>.mui-tab-item.mui-active");
				if(defaultTab !== current) {
					current.classList.remove('mui-active');
					defaultTab.classList.add('mui-active');
				}
			});
			document.addEventListener('gpBuyHousePage',function(){
				var buyTab = document.getElementById("buyTab");
				mui.trigger(buyTab,'tap');
				var current = document.querySelector(".mui-bar-tab>.mui-tab-item.mui-active");
				if(buyTab !== current) {
					current.classList.remove('mui-active');
					buyTab.classList.add('mui-active');
				}
			});
			document.addEventListener('gpSellHousePage',function(){
				var sellTab = document.getElementById("sellTab");
				mui.trigger(sellTab,'tap');
				var current = document.querySelector(".mui-bar-tab>.mui-tab-item.mui-active");
				if(sellTab !== current) {
					current.classList.remove('mui-active');
					sellTab.classList.add('mui-active');
				}
			});
		</script>
	</body>

</html>